<?php
/**
 * 秒杀活动控制器
 * @author lee
 */
namespace app\manage\controller;

use app\common\model\Goods;
use app\common\model\Activity;

class Spike extends Base
{

    public function indexAttach($data)
    {
        $this->goodsname();//商品信息
        $this->activity();
    }
    /**
     * 添加/编辑活动
     * @param array $info 编辑的信息
     */
    public function addAttach($info)
    {
        $this->goodsname();//商品信息
        $this->activity();
    }
    public function goodsname()
    {
        $good = Goods::field('id,goods_name')->order('id ASC')->select();
        $this->assign('good', $good);
    }
    /*搜索商品信息*/
    public function goods()
    {
        $post = input('post.');
        if ($post['name']) {
            $name = $post['name'];
            $where[] = [
                ['goods_name', 'like', '%'.$name.'%'],
            ];
        }
        $goods = Goods::field('id,goods_name')->where($where)->order('id ASC')->select();
        echo json_encode($goods);
    }
   
    
    /**
    
    * 获取所有活动
    
    */
    
    private function activity()
    
    {
    
    	$activity = Activity::field('id,title')->where('status','<',2)->order('id ASC')->select();
    
    	$this->assign('activity', $activity);
    
    }

}
